// 废弃
import {Api2} from './Api2';
import axios from 'axios';

// Post请求
const Service2 = {
    // doPost(url, data) {
    //     return new Promise((resolve, reject) => {
    //         axios.post(url, data).then(response => {
    //             console.log(response);
    //         }).catch(err => {
    //             console.log(err)
    //         })
    //     })
    // },
    doGet(url, data) {
        return new Promise((resolve, reject) => {
            axios.get(url, {
                params: data
            }).then(response => {
                if (response.status === 200) {
                    resolve(response.data)
                } else {
                    console.log("状态错误，暂不处理")
                }
            }).catch(error => {
                console.log(error)
            })
        })
    }
};
Service2.utils = {};
Service2.base = {
    search(keywords) {
        return Service2.doGet(Api2.baseUrl + Api2.Music.search, {
            keywords
        })
    },
    playMusic(id) {
        return Service2.doGet(Api2.baseUrl + Api2.Music.playMusic, {
            id
        })
    },
    lyric(id) {
        return Service2.doGet(Api2.baseUrl + Api2.Music.lyric, {
            id
        })
    }
};

export default Service2;